package java8.date;

import java.sql.Date;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoField;

public class LocalDateTimeDemo {
    public static void main(String[] args) {
        LocalDateTime other = LocalDateTime.of(2019, 3, 10, 12, 12, 12);

        System.out.println(other.format(DateTimeFormatter.ofPattern("yyyy-mm-dd hh:MM")));
        //10
        System.out.println(other.getDayOfWeek());
        //10
        System.out.println(other.getDayOfMonth());
        //69
        System.out.println(other.getDayOfYear());
        //2019
        System.out.println(other.getYear());
        //MARCH
        System.out.println(other.getMonth());
        //3
        System.out.println(other.getMonthValue());

        //第几分钟
        System.out.println(other.getMinute());

        //这一天多少分钟
        System.out.println(other.getLong(ChronoField.MINUTE_OF_DAY));

        Instant instant = other.atZone(ZoneId.systemDefault()).toInstant();

        System.out.println(Date.from(instant));

    }
}
